﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Web;
using System.Web.SessionState;
using DTcms.Web.UI;
using DTcms.Common;

namespace DTcms.Web.m
{
    /// <summary>
    /// get_userinfo 的摘要说明
    /// </summary>
    public class get_userinfo : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            int cur_id = DTRequest.GetFormInt("cur_id", 0);
            int target_id = DTRequest.GetFormInt("target_id", 0);

            //根据ID获取相应的内容
            StringBuilder strTxt = new StringBuilder();
            strTxt.Append("{");
            Model.users modelCur = new BLL.users().GetModel(cur_id);
            if (modelCur != null)
            {
                strTxt.Append("\"cur_username\":\"" + modelCur.user_name + "\",");
                if (modelCur.avatar.Contains("shicaiquanzi"))
                {
                    strTxt.Append("\"cur_avatar\":\"http://" + modelCur.avatar + "\",");
                }
                else
                {
                    strTxt.Append("\"cur_avatar\":\"http://www.shicaiquanzi.com" + modelCur.avatar + "\",");
                }
                
            }
            Model.users modelTo = new BLL.users().GetModel(target_id);
            if (modelTo != null)
            {
                strTxt.Append("\"to_username\":\"" + modelTo.user_name + "\",");
                if (modelTo.avatar.Contains("shicaiquanzi"))
                {
                    strTxt.Append("\"to_avatar\":\"http://" + modelTo.avatar + "\"");
                }
                else
                {
                    strTxt.Append("\"to_avatar\":\"http://www.shicaiquanzi.com" + modelTo.avatar + "\"");
                }
                
            }
            strTxt.Append("}");
            context.Response.Write(strTxt.ToString());
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}